<?php

namespace App\Models;

use App\Models\Member;

use Illuminate\Database\Eloquent\Model;

class MemberScoreLog extends Model
{

    protected $table = "member_score_log";

    protected $fillable = ['member_id', 'action', 'score', 'current_score', 'remark'];

    protected $visible = ['id', 'member_id', 'member_name','action', 'score', 'current_score', 'remark', 'created_at','updated_at'];

    protected $casts = [
        'created_at' => 'Y-m-d H:i:s',
        'updated_at' => 'Y-m-d H:i:s',
    ];

    protected $appends = ['score'];

    public function getScoreAttribute()
    {
        return abs($this->attributes['score']);
    }

    public function member()
    {
        return $this->belongsTo(Member::class, 'member_id');
    }

}
